class AddIndexes < ActiveRecord::Migration
  def self.up
    # bets
    add_index :bets,:user_id
    add_index :bets,:match_id
    add_index :bets,:team_id

    # leagues
    add_index :leagues,:sport_id
    add_index :leagues,:country_id

    # matches
    add_index :matches,:home_team_id
    add_index :matches,:away_team_id
    add_index :matches,:sport_id
    add_index :matches,:league_id

    # teams
    add_index :teams,:sport_id

    # user_prizes
    add_index :user_prizes,[:user_id,:prize_id]

    # users
    add_index :users,:facebook_id
    add_index :users,:winstreak_id
    add_index :users,:prize_id

    # winstreaks
    add_index :winstreaks,:user_id
    add_index :winstreaks,:prize_id

  end

  def self.down

    remove_index :winstreaks, :column => :prize_id
    remove_index :winstreaks, :column => :user_id
    # winstreaks

    remove_index :users, :column => :prize_id
    remove_index :users, :column => :winstreak_id
    remove_index :users, :column => :facebook_id
    # users

    remove_index :user_prizes, :column => [:user_id,:prize_id]
    # user_prizes

    remove_index :teams, :column => :sport_id
    # teams

    remove_index :matches, :column => :league_id
    remove_index :matches, :column => :sport_id
    remove_index :matches, :column => :away_team_id
    remove_index :matches, :column => :home_team_id
    # matches

    remove_index :leagues, :column => :country_id
    remove_index :leagues, :column => :sport_id
    # leagues

    remove_index :bets, :column => :team_id
    remove_index :bets, :column => :match_id
    remove_index :bets, :column => :user_id
    # bets
  end
end
